"""Deleted Cart model

Revision ID: 6da6834b9efb
Revises: 2b97252add64
Create Date: 2024-02-28 11:35:06.165423

"""
import sqlalchemy as sa
from alembic import op
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision = "6da6834b9efb"
down_revision = "2b97252add64"
branch_labels = None
depends_on = None


def upgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table("cart_product")
    op.drop_table("cart")
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        "cart",
        sa.Column(
            "id",
            sa.INTEGER(),
            server_default=sa.text("nextval('cart_id_seq'::regclass)"),
            autoincrement=True,
            nullable=False,
        ),
        sa.Column("user_id", sa.INTEGER(), autoincrement=False, nullable=False),
        sa.Column(
            "created_at",
            postgresql.TIMESTAMP(),
            server_default=sa.text("now()"),
            autoincrement=False,
            nullable=True,
        ),
        sa.Column(
            "updated_at",
            postgresql.TIMESTAMP(),
            server_default=sa.text("now()"),
            autoincrement=False,
            nullable=True,
        ),
        sa.ForeignKeyConstraint(["user_id"], ["user.id"], name="fk_cart_user_id_user"),
        sa.PrimaryKeyConstraint("id", name="pk_cart"),
        sa.UniqueConstraint("user_id", name="uq_cart_user_id"),
        postgresql_ignore_search_path=False,
    )
    op.create_table(
        "cart_product",
        sa.Column("id", sa.INTEGER(), autoincrement=True, nullable=False),
        sa.Column("product_id", sa.INTEGER(), autoincrement=False, nullable=False),
        sa.Column("cart_id", sa.INTEGER(), autoincrement=False, nullable=True),
        sa.Column("quantity", sa.INTEGER(), autoincrement=False, nullable=False),
        sa.Column(
            "created_at",
            postgresql.TIMESTAMP(),
            server_default=sa.text("now()"),
            autoincrement=False,
            nullable=True,
        ),
        sa.Column(
            "updated_at",
            postgresql.TIMESTAMP(),
            server_default=sa.text("now()"),
            autoincrement=False,
            nullable=True,
        ),
        sa.Column("final_unit_price", sa.DOUBLE_PRECISION(precision=53), autoincrement=False, nullable=False),
        sa.ForeignKeyConstraint(["cart_id"], ["cart.id"], name="fk_cart_product_cart_id_cart"),
        sa.ForeignKeyConstraint(["product_id"], ["product.id"], name="fk_cart_product_product_id_product"),
        sa.PrimaryKeyConstraint("id", name="pk_cart_product"),
    )
    # ### end Alembic commands ###
